package com.dmz.java.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class SingleThreadExecutorTest implements Runnable {
	private Integer index;

	public SingleThreadExecutorTest(Integer index) {
		this.index = index;
	}

	public static void main(String args[]) {
		ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor();
		System.out.println("****************************newFixedThreadPool*******************************");
		for (int i = 0; i < 100; i++) {
			final int index = i;
			newSingleThreadExecutor.execute(new SingleThreadExecutorTest(index));
		}
	}

	@Override
	public void run() {
		try {
			System.out.println("开始处理线程！！！");
			Thread.sleep(index * 100);
			System.out.println("我的线程标识是：" + this.toString()+":"+Thread.currentThread().getName());
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

	}
}
